import pandas as pd


'''将data的单层dict格式转为df'''
def dict2frame(dic: dict) -> pd.DataFrame:
    df = pd.concat((df.iloc[-1] for df in dic.values()), axis=1)
    df.columns = list(dic.keys())
    return df


'''将data的双层dict格式转为df'''
def multikeysdict2frame(dic: dict) -> pd.DataFrame:
    df = pd.DataFrame.from_dict({(i, j): dic[i][j]
                                                 for i in dic.keys()
                                                 for j in dic[i].keys()},
                                         orient='index')
    return df


# ,分隔的多个ts_code
def list2string(x: list)->str:
    tmpString  = ''
    for index in x:
        tmpString += ',' + str(index)
    return tmpString[1:]